#ifndef PALETTEDOCK_H
#define PALETTEDOCK_H

#include <QDockWidget>

class PaletteLabel;
class QToolButton;
class QButtonGroup;
class QRadioButton;
class QSlider;
class QLineEdit;

class PaletteDock : public QDockWidget
{
    Q_OBJECT
public:
    explicit PaletteDock(const QString &title, QWidget *parent = Q_NULLPTR,
                         Qt::WindowFlags flags = Qt::WindowFlags());
    virtual ~PaletteDock();

    void initTrans();

private:
    void initSettingWidget();
    void initForeBackWidget();
    void initPaletteWidget();
    void initRGBWidget();
    void connetSignalToSlots();

    void setButtonColor(QToolButton* button, int r, int g, int b);

signals:
    void RGBChannelChanged(int channel, int RDegree, int GDegree, int BDegree);

private slots:
    void onForeBackChanged(int i);
    void onChannelChanged(int channel);
    void onRChanged(int r);
    void onGChanged(int g);
    void onBChanged(int b);

    void onRGBChannelChanged(int channel, int RDegree, int GDegree, int BDegree);

    void onRLineEdited();
    void onGLineEdited();
    void onBLineEdited();

    void onMainLabelCursorChanged(const QPoint& p);
    void onSideLabelCursorChanged(const QPoint& p);

private:
    int m_nCurR;
    int m_nCurG;
    int m_nCurB;
    int m_nCurChannel;

private:
    QWidget* m_pWidget;

    QWidget* m_pForeBackWidget;
    QRadioButton* m_pForegroundRadioButton;
    QRadioButton* m_pBackgroundRadioButton;
    QButtonGroup* m_pForeBackButtonGroup;
    QToolButton* m_pForegroundColorButton;
    QToolButton* m_pBackgroundColorButton;

    QWidget* m_pPaletteWidget;
    PaletteLabel* m_pMainPaletteLabel;
    PaletteLabel* m_pSidePaletteLabel;

    QWidget* m_pRGBWidget;
    QButtonGroup* m_pRGBButtonGroup;
    QRadioButton* m_pRRadioButton;
    QRadioButton* m_pGRadioButton;
    QRadioButton* m_pBRadioButton;
    QSlider* m_pRSlider;
    QSlider* m_pGSlider;
    QSlider* m_pBSlider;
    QLineEdit* m_pRLineEdit;
    QLineEdit* m_pGLineEdit;
    QLineEdit* m_pBLineEdit;
};

#endif // PALETTEDOCK_H
